/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bll;

/**
 *
 * @author Le Thai
 */
import dal.DbAccess;
import java.sql.ResultSet;
import java.util.ArrayList;
import object.DsLop;
import object.Lop;
public class LopBll {
    private ResultSet res=null;
    public LopBll(){
    
    }
    
    public DsLop layDsLop(int MaNH){
        DbAccess dbAccess=new DbAccess();
        ArrayList<Lop> dsCacLop=new ArrayList<>();
        String query="exec layDsLopTheoNam "+MaNH;
        res=dbAccess.getResultSet(query);
        try {
            while(res.next()){
                int maLop=res.getInt(1);
                int maNamHoc=res.getInt(2);
                String tenLop=res.getString(3);
                dsCacLop.add(new Lop(maLop,maNamHoc,tenLop));
            }
            
        } catch (Exception e) {
            System.out.println("[LopBll][layDsCacLop]"+e.getMessage());
        }
        DsLop dsLop=new DsLop(dsCacLop);
        return dsLop;
    }
}
